
"""
14. 最长公共前缀
https://leetcode.cn/problems/longest-common-prefix/
"""

class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        """
        只是求公共前缀
        """
        # 利用字符串的排序，难道第1和最后一个字符串
        min_str, max_str = min(strs), max(strs)
        res = ""
        for i in range(len(min_str)):
            if min_str[i] == max_str[i]:
                res += min_str[i]
            else:
                break
        
        return res